﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BHXJDOTNET;
using BHXJDOTNET.NEW;
using BHXJDOTNET.OLD;
using System.Drawing.Drawing2D;

namespace 测试窗体
{
    public partial class UserControl3 : UserControl
    {
        public UserControl3()
        {
            InitializeComponent();
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics g = e.Graphics;
            //g.SmoothingMode = SmoothingMode.AntiAlias;
            g.DrawLine(new Pen(Color.White), 0f, 0f, 100f, 0f);
            g.DrawLine(new Pen(Color.White), 0f, 0f, 0f, 100f);
            g.TranslateTransform(10f,10f);
            RectangleF rf = new RectangleF();

           
            Bitmap bitmap = new Bitmap(5, 5);
            {
               
                Graphics gg = Graphics.FromImage(bitmap);
                //gg.SmoothingMode = SmoothingMode.AntiAlias;
                gg.TranslateTransform(5f / 2 - 0.5f, 5f / 2 - 0.5f);
                this.SetRectangleF(5,ref rf);
                gg.FillRectangle(new SolidBrush(Color.White), rf);
                //gg.DrawEllipse(new Pen(Color.White), rf);
            }
            this.SetRectangleF(5, ref rf);
            g.DrawImage(bitmap, rf);

            g.DrawLine(new Pen(Color.Red), 0f,0f,10f,0f);
            g.RotateTransform(90);
            g.DrawLine(new Pen(Color.Lime), 1f, 0f, 10f, 0f);
            g.RotateTransform(90);
            //g.DrawLine(new Pen(Color.Black), 0f, 0f, 10f, 0f);
            //Pen p = new Pen(Color.Red,1);
            //g.DrawLine(p, 0, 0, 0, this.Height);

        }

        private void SetRectangleF(float rfb, ref RectangleF rf)
        {
            float xy = -(rfb * 0.5f - 0.5f);
            rf.Location = new PointF(xy, xy);
            rf.Size = new SizeF(rfb, rfb);
        }
    }
}
